<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="author" content="order by dede58.com"/>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>公告 - 简博客管理系统</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<link rel="apple-touch-icon-precomposed" href="images/icon/icon.jpg">
<link rel="shortcut icon" href="images/icon/icon.jpg">
<script src="js/jquery-2.1.4.min.js"></script>
<!--[if gte IE 9]>
  <script src="js/jquery-1.11.1.min.js" type="text/javascript"></script>
  <script src="js/html5shiv.min.js" type="text/javascript"></script>
  <script src="js/respond.min.js" type="text/javascript"></script>
  <script src="js/selectivizr-min.js" type="text/javascript"></script>
<![endif]-->
<!--[if lt IE 9]>
  <script>window.location.href='upgrade-browser.html';</script>
<![endif]-->
</head>

<body class="user-select">
<section class="container-fluid">
  <header>
    <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">切换导航</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
          <a class="navbar-brand" href="/">简博客</a> </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="">消息 <span class="badge">1</span></a></li>
            <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">admin <span class="caret"></span></a>
              <ul class="dropdown-menu dropdown-menu-left">
                <li><a title="查看或修改个人信息" data-toggle="modal" data-target="#seeUserInfo">个人信息</a></li>
                <li><a title="查看您的登录记录" data-toggle="modal" data-target="#seeUserLoginlog">登录记录</a></li>
              </ul>
            </li>
            <li><a href="/Index/outLogin" onClick="if(!confirm('是否确认退出？'))return false;">退出登录</a></li>
            <li><a data-toggle="modal" data-target="#WeChat">帮助</a></li>
          </ul>
          <form action="" method="post" class="navbar-form navbar-right" role="search">
            <div class="input-group">
              <input type="text" class="form-control" autocomplete="off" placeholder="键入关键字搜索" maxlength="15">
              <span class="input-group-btn">
              <button class="btn btn-default" type="submit">搜索</button>
              </span> </div>
          </form>
        </div>
      </div>
    </nav>
  </header>
  <div class="row">
    <aside class="col-sm-3 col-md-2 col-lg-2 sidebar">
      <ul class="nav nav-sidebar">
        <li><a href="main.html">报告</a></li>
      </ul>
      <ul class="nav nav-sidebar">
        <li><a href="http://localhost:63342/springboot-blogweb/article.html">文章</a></li>
        <li class="http://localhost:63342/springboot-blogweb/active"><a href="notice.html">公告</a></li>
        <li><a href="http://localhost:63342/springboot-blogweb/comment.html">评论</a></li>
        <li><a href="http://localhost:63342/springboot-blogweb/readermsg.html">留言</a></li>
      </ul>
      <ul class="nav nav-sidebar">
        <li><a href="category.html">栏目</a></li>
        <li><a class="dropdown-toggle" id="otherMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">其他</a>
          <ul class="dropdown-menu" aria-labelledby="otherMenu">
            <li><a href="user-group.html">友情链接</a></li>
            <li><a href="loginlog.html">访问记录</a></li>
          </ul>
        </li>
      </ul>
      <ul class="nav nav-sidebar">
        <li><a class="dropdown-toggle" id="userMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">用户</a>
          <ul class="dropdown-menu" aria-labelledby="userMenu">
            <li><a href="user-group.html">管理用户组</a></li>
            <li><a href="manage-user.html">管理用户</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="http://localhost:63342/springboot-blogweb/loginlog.html">管理登录日志</a></li>
            <li><a href="http://localhost:63342/springboot-blogweb/optionlog.html">管理操作日志</a></li>
          </ul>
        </li>
        <li><a class="dropdown-toggle" id="settingMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">设置</a>
          <ul class="dropdown-menu" aria-labelledby="settingMenu">
            <li><a href="setting.html">基本设置</a></li>
            <li><a href="readset.html">用户设置</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="safety.html">安全配置</a></li>
            <li role="separator" class="divider"></li>
            <li class="disabled"><a>扩展菜单</a></li>
          </ul>
        </li>
      </ul>
    </aside>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-2 main" id="main">
      <form action="/Article/checkAll" method="post" >
        <h1 class="page-header">操作</h1>
        <ol class="breadcrumb">
          <li><a href="http://localhost:63342/springboot-blogweb/add-notice.html" class="tn btn-primary btn-sm"><span class="glyphicon glyphicon-plus"></span>增加公告</a></li>
        </ol>
        <div class="table-responsive">
          <table class="table table-striped table-hover">
            <thead>
              <tr>
                <th><span class="glyphicon glyphicon-file"></span> <span class="visible-lg">ID</span></th>
                <th><span class="glyphicon glyphicon-time"></span> <span class="visible-lg">内容</span></th>
                <th><span class="glyphicon glyphicon-time"></span> <span class="visible-lg">时间</span></th>
                <th><span class="glyphicon glyphicon-pencil"></span> <span class="visible-lg">操作</span></th>
              </tr>
            </thead>
            <tbody id="container">
             
            </tbody>
          </table>
        </div>
      </form>
    </div>
  </div>
</section>

<script src="js/bootstrap.min.js"></script> 
<script src="js/admin-scripts.js"></script> 
<script type="text/javascript">
  /**
   * 定义全局公告notice数组信息
   * 把返回的data数据都放入这个数据，然后在遍历数组
   */
var noticesList = [];
//发送ajax请求，获取contents信息
$(function(){

     /**
     * 1.显示所有公告
     * @param pn
     */
      $.ajax({
          url:"http://localhost:8081/notice/selectAllNotice",
          type:"GET",
          xhrFields:{
            widthCredentials:true
          },
          success:function (result) {
              if (0 == result.code){
                 noticesList = result.data;
                 //重新加载
                 reloadDom();
              }
          }

      });


  /**
   * contents列表浏览
   * 遍历数组，append到tbody中
   * 之后给每行添加id，方便获取每个content的详情信息
   */
  function reloadDom(){
      $("#container").empty();
      for (var i=0; i<noticesList.length; i++) {
          var noticeDo = noticesList[i];
          var dom = "<tr data-id='"+noticeDo.id+"'><td>"+noticeDo.id+"</td>\n" +
            "<td>"+noticeDo.content+"</td>\n" +
            "<td>"+noticeDo.createTime+"</td>\n" +
            "<td><input class='btn btn-primary btn-sm edit_btn' type='button' id='noticeDoItem"+noticeDo.id+"' value='修改'><input class='tn btn-danger btn-sm delete_btn' type='button' value='删除'></td></tr>";;
              //添加到tbody容器中
          $("#container").append($(dom));
         
      }
  }
});
</script>
</body>
</html>
